//
// Created by work on 24-8-22.
//

#ifndef IOT_PLAT_CSSQLMGR_H
#define IOT_PLAT_CSSQLMGR_H
#include <os/miscellany/stddef.h>
#include <dist/json/json.h>
#include <iot_model_device/CModelInfo.h>
#include <iot_model_device/CUserInfo.h>
#include <iot_model_device/CRtDeviceInfo.h>
#include <iostream>
#include <string>

using namespace iotplat;

class CSsqlMgr {
    STATIC_SINGLETON(CSsqlMgr);
public:
    [[maybe_unused]] static bool addUser(Json::Value user);

    [[maybe_unused]] static bool delUser(const std::string& userid);

    [[maybe_unused]] static bool changeUser(Json::Value user);

    [[maybe_unused]] static bool getUser(const std::string& userid, Json::Value& user);

    [[maybe_unused]] static bool checkUserNoExist(const std::string& userid);

    [[maybe_unused]] static bool addModel(const CModelInfo& model);

    [[maybe_unused]] static bool delModel(const std::string& userid, const std::string& name);

    [[maybe_unused]] static bool changeModel(const CModelInfo& model);

    [[maybe_unused]] static bool getModel(const std::string& userid, const std::string& name, CModelInfo& model);

    [[maybe_unused]] static bool getModels(const std::string& userid, std::vector<CModelInfo>& models);

    [[maybe_unused]] static bool addyx(const CRtModelYxInfo& yx);

    [[maybe_unused]] static bool delYx(const std::string& userid, const std::string& modelname, const std::string& name);

    [[maybe_unused]] static bool changeYx(const CRtModelYxInfo& yx);

    [[maybe_unused]] static bool getYx(const std::string& userid, const std::string& modelname, const std::string& name, CRtModelYxInfo& yx);

    [[maybe_unused]] static bool getYxs(const std::string& userid, const std::string& modelname, std::vector<CRtModelYxInfo>& yxs);

    [[maybe_unused]] static bool addyc(const CRtModelYcInfo& yc);

    [[maybe_unused]] static bool delYc(const std::string& userid, const std::string& modelname, const std::string& name);

    [[maybe_unused]] static bool changeYc(const CRtModelYcInfo& yc);

    [[maybe_unused]] static bool getYc(const std::string& userid, const std::string& modelname, const std::string& name, CRtModelYcInfo& yc);

    [[maybe_unused]] static bool getYcs(const std::string& userid, const std::string& modelname, std::vector<CRtModelYcInfo>& ycs);

    [[maybe_unused]] static bool addyk(const CRtModelYkInfo& yk);

    [[maybe_unused]] static bool delYk(const std::string& userid, const std::string& modelname, const std::string& name);

    [[maybe_unused]] static bool changeYk(const CRtModelYkInfo& yk);

    [[maybe_unused]] static bool getYk(const std::string& userid, const std::string& modelname, const std::string& name, CRtModelYkInfo& yk);

    [[maybe_unused]] static bool getYks(const std::string& userid, const std::string& modelname, std::vector<CRtModelYkInfo>& yks);

    [[maybe_unused]] static bool addParameter(const CRtModelParameterInfo& parameter);

    [[maybe_unused]] static bool delParameter(const std::string& userid, const std::string& modelname, const std::string& name);

    [[maybe_unused]] static bool changeParameter(const CRtModelParameterInfo& parameter);

    [[maybe_unused]] static bool getParameter(const std::string& userid, const std::string& modelname, const std::string& name, CRtModelParameterInfo& parameter);

    [[maybe_unused]] static bool getParameters(const std::string& userid, const std::string& modelname, std::vector<CRtModelParameterInfo>& parameters);

    [[maybe_unused]] static bool addDevice(CRtDeviceInfo& device);

    [[maybe_unused]] static bool delDevice(const std::string& userid, const std::string& modelname, const std::string& name);

    [[maybe_unused]] static bool changeDevice(const CRtDeviceInfo& device);

    [[maybe_unused]] static bool getDevice(const std::string& userid, const std::string& modelname, const std::string& name, CRtDeviceInfo& device);

    [[maybe_unused]] static bool getDevices(const std::string& userid,const std::string& modelname, std::vector<CRtDeviceInfo>& devices);

    /********************************************modbus映射相关*********************************************/
    [[maybe_unused]] static bool getModbusMaps(const std::string& userid, const std::string& model_name, Json::Value& modbusMaps);
    [[maybe_unused]] static bool addModbusMap(Json::Value& map);
    [[maybe_unused]] static bool delModbusMap(const std::string& map_id);

    [[maybe_unused]] static bool addModbusMapYxs(const std::string& map_id, Json::Value& mapyxs);
    [[maybe_unused]] static bool changeModbusMapYxs(const std::string& map_id, Json::Value& mapyxs);
    [[maybe_unused]] static bool deleteModbusMapYxs(const std::string& map_id, Json::Value& mapyxs);
    [[maybe_unused]] static bool getModbusMapYxs(const std::string& map_id, Json::Value& mapsigs);

    [[maybe_unused]] static bool addModbusMapYcs(const std::string& map_id, Json::Value& mapycs);
    [[maybe_unused]] static bool changeModbusMapYcs(const std::string& map_id, Json::Value& mapycs);
    [[maybe_unused]] static bool deleteModbusMapYcs(const std::string& map_id, Json::Value& mapycs);
    [[maybe_unused]] static bool getModbusMapYcs(const std::string& map_id, Json::Value& mapsigs);

    [[maybe_unused]] static bool addModbusMapYks(const std::string& map_id, Json::Value& mapyks);
    [[maybe_unused]] static bool changeModbusMapYks(const std::string& map_id, Json::Value& mapyks);
    [[maybe_unused]] static bool deleteModbusMapYks(const std::string& map_id, Json::Value& mapyks);
    [[maybe_unused]] static bool getModbusMapYks(const std::string& map_id, Json::Value& mapsigs);

    [[maybe_unused]] static bool addModbusMapParameters(const std::string& map_id, Json::Value& mapparameters);
    [[maybe_unused]] static bool changeModbusMapParameters(const std::string& map_id, Json::Value& mapparameters);
    [[maybe_unused]] static bool deleteModbusMapParameters(const std::string& map_id, Json::Value& mapparameters);
    [[maybe_unused]] static bool getModbusMapParameters(const std::string& map_id, Json::Value& mapsigs);

protected:
    static bool delSig(const std::string& userid, const std::string& modelname, const std::string& name, const std::string& table);
};
#endif //IOT_PLAT_CSSQLMGR_H
